from sqlalchemy.orm import Session
from database.crud.schedule_dao import ScheduleDAO
from datetime import datetime
from typing import Optional

class ScheduleService:
    @staticmethod
    def add_schedule(db: Session, user_id: int, title: str, start_time: datetime, end_time: Optional[datetime], reminder_at: Optional[datetime], notes: Optional[str]):
        return ScheduleDAO.create_schedule(
            db=db,
            user_id=user_id,
            title=title,
            start_time=start_time,
            end_time=end_time,
            reminder_at=reminder_at,
            notes=notes
        )

    @staticmethod
    def update_schedule(db: Session, schedule_id: int, **kwargs):
        return ScheduleDAO.update_schedule(db, schedule_id, **kwargs)

    @staticmethod
    def delete_schedule(db: Session, schedule_id: int):
        return ScheduleDAO.delete_schedule(db, schedule_id)

    @staticmethod
    def list_user_schedules(db: Session, user_id: int):
        return ScheduleDAO.get_user_schedules(db, user_id)